<template>
  <div>
    <ul style="padding:50rpx;">
      <li class="lidi">上课日期：{{start}}</li>
      <li class="lidi">上课时间：{{schooltime}}</li>
      <li class="lidi indet">班级：{{data}}</li>
      <li class="lidi indet">校区：{{xiaoqu}}</li>
      <li class="lidi indet">教室：{{classban}}</li>
      <li class="lidi indet">教师：{{teacher}}</li>
      <li class="lidi indet">助教：{{zhuteacher}}</li>
      <li class="lidi" v-if="info!='null'">课程内容：{{info}}</li>
    </ul>
    <button :disabled="disabled" @click="handleOpen2" class="qs_btn">{{btn_title}}</button>
    <i-modal :visible="visible2" @ok="handleClose2" @cancel="handleClose3">
    <view >您确定在{{start}}为孩子{{btn_title}}吗？</view>
</i-modal>
  </div>
</template>
<script>
export default {
  data() {
    return {
      ID: "",
       classban:"",
      data:"",
      schooltime:"",
      start:"",
      teacher:"",
       xiaoqu:"",
       hour:"",
       type:"",
       schoolclazzstudentcalendarID:"",
       schooluserids:"",
       info:"",
       zhuteacher:"",
      btn_title: "请假",
      visible2: false,
      startqs: false,
    };
  },
  onLoad(option) {
    console.log(option)
    this.classban = option.classban;
    this.data = option.data;
    this.schooltime = option.schooltime;
    this.start = option.start;
    this.teacher = option.teacher;
    this.ID = option.id;
    this.hour = option.hour;
    this.type = option.type;
    this.schoolclazzstudentcalendarID = option.schoolclazzstudentcalendarID;
    this.info = option.info;
    this.schooluserids = option.schooluserids;
  },
   mounted(){
    this.startss()
  },
  methods: {
     startss(){
       if(this.type=="请假"){
         this.btn_title="撤销请假"
       }else{
         this.btn_title="请假"
       }
      var that = this
      const ressid = wx.getStorageSync("loginUserInfo").schooladdressid;
       //校区
      const ID=ressid
      wx.request({
        url: that.$interfaces.addressid+"/"+ID,
        method: "get",
        success: function(res) {
          that.xiaoqu=res.data.name
        }
      });
      const userid=this.schooluserids
       wx.request({
        url: that.$interfaces.userid+"/"+userid,
        method: "get",
        success: function(res) {
          that.zhuteacher=res.data.name
        }
      });
    },
    btn_click(){

    },
    handleOpen2 () {
            this.visible2= true
    },
    handleClose2 () {
       const schoolstudentid = wx.getStorageSync("loginUserInfo").ID;
       const schoolclazzscheduleid =this.ID;
       const hour =this.hour;

      if(this.btn_title=="请假"){
        this.btn_title="撤销请假"
        this.visible2= false
        const type="请假"
        var that =this
         wx.request({
              url: that.$interfaces.addclass+"/"+schoolstudentid+"/"+schoolclazzscheduleid+"/"+type+"/"+hour,
              method: "get",
              success: function(res) {
                console.log(res)
              }
         })
      }else if(this.btn_title=="撤销请假") {
        this.btn_title="请假"
        this.visible2= false
        const ID =this.schoolclazzstudentcalendarID;
        var that =this
         wx.request({
              url: that.$interfaces.deleressid+"/"+ID,
              method: "get",
              success: function(res) {
                console.log(res)
              }
         })
       }
    },
    handleClose3(){
     this.visible2= false
    }
  },
};
</script>
<style>
  .qs_btn {
  position: absolute;
  top: 90%;
  left: 10%;
  width: 80%;
  background: #0099FF;
  color: #fff;
  border-radius: 5px;
}
.lidi{
  margin-bottom:30rpx;
}
.indet{
  text-indent:2em;
}
</style>
